<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //  async函数 是promise的语法糖  快速完成异步操作
      // async 函数必须结合await 使用
      // await 接异步操作
      async function fisetAsync() {
        let p1 = new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve('异步操作3秒的')
          }, 3000)
        })
        await p1.then(res => {
          console.log(res)
        })
        await p2.then(res => {
          console.log(res)
        })
        console.log('你好')
        let p2 = new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve('异步操作1秒的')
          }, 1000)
        })

        console.log(222)
        return Promise.resolve(888)
      }
      fisetAsync().then(res => {
        console.log(res)
      })
    </script>
  </body>
</html>
